﻿var indicationViewVM = {
    Indications: ko.observableArray([]),
    loadRequest: null,
    cancelLoadRequest: function () {
        var self = this;
        if (self.loadRequest != null) {
            self.loadRequest.abort();
        }
    },
    loadIndication: function (indicationID, indexController) {
        var self = this;
        indexController.message.processing("loading");
        //self.Indications.removeAll();
        self.Indications.destroyAll();
        self.loadRequest = $.ajax({
            type: 'post',
            url: home + 'Doctor/GetIndication',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify({ id: indicationID }),
            success: function (data, textStatus) {
                self.Indications(data[0]);
                indexController.message.processComplete("load_complete");
            },
            error: function (err) {
                if (err.status == 200) {
                    indexController.message.processComplete(err.responseText);
                }
                else {
                    indexController.message.processComplete("load_error");
                }
            }
        });
    }
};